package cc.z8g.browser.core.config;

import android.webkit.CookieManager;

import cc.z8g.browser.utils.MiscUtils;
import cc.z8g.browser.utils.sp.UserSp;

/**
 * The administrator used to manage browser cookie preferences.
 */
public class CookieAdministrator {

    /**
     * Adjust the cookie setting based on the current preferences.
     */
    public static void adjustCookieSettings(boolean isIncognitoMode) {
        if (isIncognitoMode && !MiscUtils.FULL_INCOGNITO) {
            CookieManager.getInstance().setAcceptCookie(UserSp.getBoolean(UserSp.KEY_INCOGNITO_THIRD_PARTY_COOKIES));
        } else {
            CookieManager.getInstance().setAcceptCookie(UserSp.getBoolean(UserSp.KEY_THIRD_PARTY_COOKIES));
        }
    }

}
